xcsv: Add support for BNG (British National Grid) coordinates.
authoroliskoli <oliskoli>
Fri, 4 May 2007 20:02:05 +0000 (20:02 +0000)
committeroliskoli <oliskoli>
Fri, 4 May 2007 20:02:05 +0000 (20:02 +0000)
csv_util.c
xmldoc/chapters/styles.xml

index a1a7edf87aa3e9790506c87200f91047616ad105..047a453dd21e3c620d3a38582151d4996ae93ee8 100644 (file)
@@ -881,7 +881,11 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp)
     if (strcmp(fmp->key, "LON_DIR") == 0) {
        /* longitude E/W. Ingore on input for now */
     } else
-
+    /* SPECIAL COORDINATES/GRID */
+    if (strcmp(fmp->key, "MAP_EN_BNG") == 0) {
+       parse_coordinates(s, DATUM_OSGB36, grid_bng,
+          &wpt->latitude, &wpt->longitude, MYNAME);
+    } else
     /* ALTITUDE CONVERSIONS ************************************************/
     if (strcmp(fmp->key, "ALT_FEET") == 0) {
        /* altitude in feet as a decimal value */
@@ -1348,6 +1352,16 @@ xcsv_waypt_pr(const waypoint *wpt)
             writebuff(buff, fmp->printfc,
               LON_DIR(lon));
         } else
+       
+       /* SPECIAL COORDINATES */
+        if (strcmp(fmp->key, "MAP_EN_BNG") == 0) {
+               char map[3];
+               double north, east;
+               if (! GPS_Math_WGS84_To_UKOSMap_M(wpt->latitude, wpt->longitude, &east, &north, map))
+                       fatal(MYNAME ": Position (%.5f/%.5f) outside of BNG.\n",
+                               wpt->latitude, wpt->longitude);
+               snprintf(buff, sizeof(buff), fmp->printfc, map, (int)(east + 0.5), (int)(north + 0.5));
+       } else
 
         /* ALTITUDE CONVERSIONS**********************************************/
         if (strcmp(fmp->key, "ALT_FEET") == 0) {
index 3f64a1d10ef928893371e8bd2fe9e5e9bb9a3288..4bd2f383571cb33021e70ad120ec1e32baebedb3 100644 (file)
@@ -646,6 +646,24 @@ examples:
 </screen>
 </section>
 
+<section id="style_def_map_en_bng">
+<title>MAP_EN_BNG</title>
+<para>
+   MAP_EN_BNG converts coordinates from/to British National Grid (BNG).
+</para>
+<para>
+   The only supported order of the items is: Map,Easting,Northing.
+   During output all coordinates have to be located within this limited area.
+</para>
+<para>
+examples:
+</para>
+<screen format="linespecific">
+   IFIELD MAP_EN_BNG,"","%s%5d %5d"   #  (writes i.e. "SJ00001 00001")
+   IFIELD MAP_EN_BNG,"","%s %d %d"    #  (writes i.e. "TQ 888 999")
+</screen>
+</section>
+
 <section id="style_def_lonhuman">
 <title>LON_HUMAN_READABLE</title>
 <para>